package com.intxt.bbs.controller;

import com.intxt.bbs.interceptor.AdminInterceptor;
import com.intxt.bbs.model.Topic;
import com.intxt.bbs.util.Const;
import com.jfinal.aop.Before;
import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.TableMapping;

import java.util.List;

/**
 * Created bbs-com.intxt.bbs.controller
 * User: GouLin
 * Date: 15/2/28
 * Time: 下午11:20
 * To change this template use File | Settings | File Templates.
 */
@Before(AdminInterceptor.class)
public class AdminController extends Controller {
    public void index(){
        Integer currentPage = getAttrForInt("currentPage");
        if (currentPage ==null){
            currentPage =1;
            setAttr("gotoPage",1);
        }else{
            setAttr("gotoPage",currentPage);
        }
        Page<Topic> page = Topic.DAO.paginate(currentPage, Const.PAGE_SIZE, "select topic.id,topic.title,topic.publish_date,user.id as uid,user.username,user.head_img_address ,user.user_group_id", "from intxt_topic topic, intxt_user user where topic.publisher_id=user.id order by publish_date desc");
        setAttr("pageInfo",page);
        render("/admin/index.jsp");
    }

    /**
     * 帖子管理
     */
    public void topicManage(){

    }


}
